const express = require('express')
    // const cors = require('cors')

const bodyParser = require('body-parser')
const passport = require('passport')

const app = express()

// 跨域配置
// app.use(cors());
// 引入路由
const userrouter = require('./router/api/user.js')
const profilerouter = require('./router/api/profile.js')

// 连接数据库
require('./model/connect.js')

// 使用bodyParser中间件
app.use(bodyParser.urlencoded({ extended: false }))
app.use(bodyParser.json())

// passport 初始化
app.use(passport.initialize())

// 如果你想要在其他模块中使用passport，那么还要引入：
require("./config/passport")(passport);

app.use('/api', userrouter)
app.use('/api/profiles', profilerouter)
const port = process.env.PORT || 5000

app.listen(port, () => {
    console.log(`Server running on port ${port}`);
})